<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>隐藏</title>
    <style>
        .father {
            width: 300px;
            height: 100px;
            background-color: yellowgreen;
        }

        .son {
            /* display: none; */
            visibility: hidden;
            width: 200px;
            height: 150px;
            background-color: tomato;
        }

        .sunzi {
            visibility: visible;
            width: 100px;
            height: 200px;
            background-color: teal;
        }
    </style>
</head>

<body>
    <!-- 
        display: none      会让元素从渲染树中消失，渲染时不占据任何空间
                           （非继承属性）因为从渲染树中消失，所以子孙节点无法显示
                           display通常会造成文档重排
        visibility: hidden 只是让元素内容看不见，但元素依然占据空间
                           （继承属性），子孙节点可设置visibility: visible继续显示
                           visibility只会造成本元素重绘
     -->
    <div class="father">
        <div class="son">
            <div class="sunzi"></div>
        </div>
    </div>
</body>

</html>